package utilities.display.defined;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Stroke;

import utilities.display.ShapedGraphic;
import utilities.display.iface.Drawable;

public class OvalGraphic extends Rectangle implements Drawable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 7248936015509928703L;
	
	/**
	 * 
	 * @param x
	 * @param y
	 * @param radius
	 * @param lineColor
	 * @param stroke
	 * @param fillColor
	 * @param dXDraw TODO
	 * @param dYDraw TODO
	 */
	public OvalGraphic(int x, int y, int radius, Color lineColor, Stroke stroke,
						Color fillColor, int dXDraw, int dYDraw) 
	{
		//super(x, y, width, lineColor, stroke, fillColor, dXDraw, dYDraw);
		super(lineColor, stroke, fillColor, dXDraw, dYDraw);
		
		for(double ang = 0.0; ang < 360.0; ang += 1.0)
		{
			//How find x?
			int px = (int)(Math.cos(Math.PI * ang / 360.0) * radius) + x;
			
			//How find y?
			int py = (int)(Math.sin(Math.PI * ang / 360.0) * radius) + y;
			
			//Add point to this.
			this.addPoint(px, py);
		}
	}

	public void drawMe(Graphics g) 
	{
		Graphics2D g2 = (Graphics2D) g;
		
		// Get previous settings...
		Color c = g2.getColor();
		Stroke s = g2.getStroke();
		
		// Draw me now!!
		
		// Fill portion...
		if(myFillColor != null)
		{
			g2.setColor(myFillColor);
			//g2.fillOval(x + drawDX, y + drawDY, width, height);
			g2.fillPolygon(this);
		}
		
		// Line portion...
		if(myLineColor != null && myLineStyle != null)
		{
			g2.setColor(myLineColor);
			g2.setStroke(myLineStyle);
			//g2.drawOval(x + drawDX, y + drawDY, width, height);
			g2.drawPolygon(this);
		}
		
		// Restore previous settings...
		g2.setColor(c);
		g2.setStroke(s);
	}
}
